﻿namespace HRM.CORE
{
    using APP.HELPER.Data.Helper;
    using APP.HELPER.Utils.CustomizeToolbox;
    using DevExpress.XtraEditors;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Windows.Forms; using Common;

    public class HRM_RECRUITMENT
    {
        private string m_DecideNumber;
        private string m_Description;
        private string m_FilePath;
        private DateTime m_FromDate;
        private int m_Quantity;
        private string m_RecruitmentCode;
        private string m_RecruitmentName;
        private int m_Status;
        private DateTime m_ToDate;

        public HRM_RECRUITMENT()
        {
            this.m_RecruitmentCode = "";
            this.m_RecruitmentName = "";
            this.m_FromDate = DateTime.Now;
            this.m_ToDate = DateTime.Now;
            this.m_Quantity = 0;
            this.m_DecideNumber = "";
            this.m_FilePath = "";
            this.m_Status = 0;
            this.m_Description = "";
        }

        public HRM_RECRUITMENT(string RecruitmentCode, string RecruitmentName, DateTime FromDate, DateTime ToDate, int Quantity, string DecideNumber, string FilePath, int Status, string Description)
        {
            this.m_RecruitmentCode = RecruitmentCode;
            this.m_RecruitmentName = RecruitmentName;
            this.m_FromDate = FromDate;
            this.m_ToDate = ToDate;
            this.m_Quantity = Quantity;
            this.m_DecideNumber = DecideNumber;
            this.m_FilePath = FilePath;
            this.m_Status = Status;
            this.m_Description = Description;
        }

        public void AddCombo(System.Windows.Forms.ComboBox combo)
        {
            GridCalendarControlLib.TableToComboBox(combo, this.GetList(), "RecruitmentName", "RecruitmentCode");
        }

        public void AddComboAll(System.Windows.Forms.ComboBox combo)
        {
            DataTable list = new DataTable();
            list = this.GetList();
            DataRow row = list.NewRow();
            row["RecruitmentCode"] = "All";
            row["RecruitmentName"] = "Tất cả";
            list.Rows.InsertAt(row, 0);
            GridCalendarControlLib.TableToComboBox(combo, list, "RecruitmentName", "RecruitmentCode");
        }

        public void AddGridLookupEdit(GridLookUpEdit gridlookup)
        {
            DataTable list = new DataTable();
            list = this.GetList();
            gridlookup.Properties.DataSource = list;
            gridlookup.Properties.DisplayMember = "RecruitmentName";
            gridlookup.Properties.ValueMember = "RecruitmentCode";
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@RecruitmentCode" };
            object[] myValues = new object[] { this.m_RecruitmentCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_RECRUITMENT_Delete", myParams, myValues);
        }

        public string Delete(string RecruitmentCode)
        {
            string[] myParams = new string[] { "@RecruitmentCode" };
            object[] myValues = new object[] { RecruitmentCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_RECRUITMENT_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, string RecruitmentCode)
        {
            string[] myParams = new string[] { "@RecruitmentCode" };
            object[] myValues = new object[] { RecruitmentCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_RECRUITMENT_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, string RecruitmentCode)
        {
            string[] myParams = new string[] { "@RecruitmentCode" };
            object[] myValues = new object[] { RecruitmentCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_RECRUITMENT_Delete", myParams, myValues);
        }

        public bool Exist(string RecruitmentCode)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@RecruitmentCode" };
            object[] myValues = new object[] { RecruitmentCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("DIC_RECRUITMENT_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(string RecruitmentCode)
        {
            string str = "";
            string[] myParams = new string[] { "@RecruitmentCode" };
            object[] myValues = new object[] { RecruitmentCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_RECRUITMENT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RecruitmentCode = Convert.ToString(reader["RecruitmentCode"]);
                    this.m_RecruitmentName = Convert.ToString(reader["RecruitmentName"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Quantity = Convert.ToInt32(reader["Quantity"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_FilePath = Convert.ToString(reader["FilePath"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, string RecruitmentCode)
        {
            string str = "";
            string[] myParams = new string[] { "@RecruitmentCode" };
            object[] myValues = new object[] { RecruitmentCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_RECRUITMENT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RecruitmentCode = Convert.ToString(reader["RecruitmentCode"]);
                    this.m_RecruitmentName = Convert.ToString(reader["RecruitmentName"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Quantity = Convert.ToInt32(reader["Quantity"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_FilePath = Convert.ToString(reader["FilePath"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, string RecruitmentCode)
        {
            string str = "";
            string[] myParams = new string[] { "@RecruitmentCode" };
            object[] myValues = new object[] { RecruitmentCode };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_RECRUITMENT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_RecruitmentCode = Convert.ToString(reader["RecruitmentCode"]);
                    this.m_RecruitmentName = Convert.ToString(reader["RecruitmentName"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Quantity = Convert.ToInt32(reader["Quantity"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_FilePath = Convert.ToString(reader["FilePath"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_RECRUITMENT_GetList");
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@RecruitmentCode", "@RecruitmentName", "@FromDate", "@ToDate", "@Quantity", "@DecideNumber", "@FilePath", "@Status", "@Description" };
            object[] myValues = new object[] { this.m_RecruitmentCode, this.m_RecruitmentName, this.m_FromDate, this.m_ToDate, this.m_Quantity, this.m_DecideNumber, this.m_FilePath, this.m_Status, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_RECRUITMENT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@RecruitmentCode", "@RecruitmentName", "@FromDate", "@ToDate", "@Quantity", "@DecideNumber", "@FilePath", "@Status", "@Description" };
            object[] myValues = new object[] { this.m_RecruitmentCode, this.m_RecruitmentName, this.m_FromDate, this.m_ToDate, this.m_Quantity, this.m_DecideNumber, this.m_FilePath, this.m_Status, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_RECRUITMENT_Insert", myParams, myValues);
        }

        public string Insert(string RecruitmentCode, string RecruitmentName, DateTime FromDate, DateTime ToDate, int Quantity, string DecideNumber, string FilePath, int Status, string Description)
        {
            string[] myParams = new string[] { "@RecruitmentCode", "@RecruitmentName", "@FromDate", "@ToDate", "@Quantity", "@DecideNumber", "@FilePath", "@Status", "@Description" };
            object[] myValues = new object[] { RecruitmentCode, RecruitmentName, FromDate, ToDate, Quantity, DecideNumber, FilePath, Status, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_RECRUITMENT_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, string RecruitmentCode, string RecruitmentName, DateTime FromDate, DateTime ToDate, int Quantity, string DecideNumber, string FilePath, int Status, string Description)
        {
            string[] myParams = new string[] { "@RecruitmentCode", "@RecruitmentName", "@FromDate", "@ToDate", "@Quantity", "@DecideNumber", "@FilePath", "@Status", "@Description" };
            object[] myValues = new object[] { RecruitmentCode, RecruitmentName, FromDate, ToDate, Quantity, DecideNumber, FilePath, Status, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_RECRUITMENT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, string RecruitmentCode, string RecruitmentName, DateTime FromDate, DateTime ToDate, int Quantity, string DecideNumber, string FilePath, int Status, string Description)
        {
            string[] myParams = new string[] { "@RecruitmentCode", "@RecruitmentName", "@FromDate", "@ToDate", "@Quantity", "@DecideNumber", "@FilePath", "@Status", "@Description" };
            object[] myValues = new object[] { RecruitmentCode, RecruitmentName, FromDate, ToDate, Quantity, DecideNumber, FilePath, Status, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_RECRUITMENT_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_RECRUITMENT", "RecruitmentCode", "TD");
        }

        public void SetData(string RecruitmentCode, string RecruitmentName, DateTime FromDate, DateTime ToDate, int Quantity, string DecideNumber, string FilePath, int Status, string Description)
        {
            this.m_RecruitmentCode = RecruitmentCode;
            this.m_RecruitmentName = RecruitmentName;
            this.m_FromDate = FromDate;
            this.m_ToDate = ToDate;
            this.m_Quantity = Quantity;
            this.m_DecideNumber = DecideNumber;
            this.m_FilePath = FilePath;
            this.m_Status = Status;
            this.m_Description = Description;
        }

        public string Update()
        {
            string[] myParams = new string[] { "@RecruitmentCode", "@RecruitmentName", "@FromDate", "@ToDate", "@Quantity", "@DecideNumber", "@FilePath", "@Status", "@Description" };
            object[] myValues = new object[] { this.m_RecruitmentCode, this.m_RecruitmentName, this.m_FromDate, this.m_ToDate, this.m_Quantity, this.m_DecideNumber, this.m_FilePath, this.m_Status, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_RECRUITMENT_Update", myParams, myValues);
        }

        public string Update(string RecruitmentCode, string RecruitmentName, DateTime FromDate, DateTime ToDate, int Quantity, string DecideNumber, string FilePath, int Status, string Description)
        {
            string[] myParams = new string[] { "@RecruitmentCode", "@RecruitmentName", "@FromDate", "@ToDate", "@Quantity", "@DecideNumber", "@FilePath", "@Status", "@Description" };
            object[] myValues = new object[] { RecruitmentCode, RecruitmentName, FromDate, ToDate, Quantity, DecideNumber, FilePath, Status, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_RECRUITMENT_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, string RecruitmentCode, string RecruitmentName, DateTime FromDate, DateTime ToDate, int Quantity, string DecideNumber, string FilePath, int Status, string Description)
        {
            string[] myParams = new string[] { "@RecruitmentCode", "@RecruitmentName", "@FromDate", "@ToDate", "@Quantity", "@DecideNumber", "@FilePath", "@Status", "@Description" };
            object[] myValues = new object[] { RecruitmentCode, RecruitmentName, FromDate, ToDate, Quantity, DecideNumber, FilePath, Status, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_RECRUITMENT_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, string RecruitmentCode, string RecruitmentName, DateTime FromDate, DateTime ToDate, int Quantity, string DecideNumber, string FilePath, int Status, string Description)
        {
            string[] myParams = new string[] { "@RecruitmentCode", "@RecruitmentName", "@FromDate", "@ToDate", "@Quantity", "@DecideNumber", "@FilePath", "@Status", "@Description" };
            object[] myValues = new object[] { RecruitmentCode, RecruitmentName, FromDate, ToDate, Quantity, DecideNumber, FilePath, Status, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_RECRUITMENT_Update", myParams, myValues);
        }

        [DisplayName("DecideNumber"), Category("Column")]
        public string DecideNumber
        {
            get
            {
                return this.m_DecideNumber;
            }
            set
            {
                this.m_DecideNumber = value;
            }
        }

        [DisplayName("Description"), Category("Column")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [DisplayName("FilePath"), Category("Column")]
        public string FilePath
        {
            get
            {
                return this.m_FilePath;
            }
            set
            {
                this.m_FilePath = value;
            }
        }

        [Category("Column"), DisplayName("FromDate")]
        public DateTime FromDate
        {
            get
            {
                return this.m_FromDate;
            }
            set
            {
                this.m_FromDate = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_RECRUITMENT";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [Category("Column"), DisplayName("Quantity")]
        public int Quantity
        {
            get
            {
                return this.m_Quantity;
            }
            set
            {
                this.m_Quantity = value;
            }
        }

        [DisplayName("RecruitmentCode"), Category("Primary Key")]
        public string RecruitmentCode
        {
            get
            {
                return this.m_RecruitmentCode;
            }
            set
            {
                this.m_RecruitmentCode = value;
            }
        }

        [Category("Column"), DisplayName("RecruitmentName")]
        public string RecruitmentName
        {
            get
            {
                return this.m_RecruitmentName;
            }
            set
            {
                this.m_RecruitmentName = value;
            }
        }

        [Category("Column"), DisplayName("Status")]
        public int Status
        {
            get
            {
                return this.m_Status;
            }
            set
            {
                this.m_Status = value;
            }
        }

        [DisplayName("ToDate"), Category("Column")]
        public DateTime ToDate
        {
            get
            {
                return this.m_ToDate;
            }
            set
            {
                this.m_ToDate = value;
            }
        }
    }
}

